{
    "cells": [
        {
            "cell_type": "code",
            "execution_count": 1,
            "metadata": {},
            "outputs": [
                {
                    "name": "stderr",
                    "output_type": "stream",
                    "text": [
                        "Some weights of the model checkpoint at ./bert-roberta were not used when initializing BertForSequenceClassification: ['bert.encoder.layer.9.attention.output.dense.weight', 'bert.encoder.layer.10.attention.output.LayerNorm.weight', 'bert.encoder.layer.2.output.dense.weight', 'bert.encoder.layer.9.output.dense.bias', 'bert.encoder.layer.5.attention.self.query.bias', 'bert.encoder.layer.3.attention.self.value.weight', 'bert.encoder.layer.8.attention.output.LayerNorm.weight', 'bert.encoder.layer.5.intermediate.dense.bias', 'bert.encoder.layer.9.output.LayerNorm.weight', 'bert.encoder.layer.2.attention.self.key.bias', 'bert.encoder.layer.11.attention.self.key.bias', 'bert.encoder.layer.8.attention.self.key.bias', 'bert.encoder.layer.5.output.LayerNorm.weight', 'bert.encoder.layer.4.intermediate.dense.weight', 'bert.encoder.layer.9.attention.self.key.bias', 'bert.encoder.layer.9.attention.output.LayerNorm.weight', 'bert.encoder.layer.5.attention.self.value.bias', 'bert.encoder.layer.6.attention.output.dense.bias', 'bert.encoder.layer.11.output.dense.weight', 'bert.encoder.layer.4.attention.output.dense.weight', 'bert.encoder.layer.7.attention.self.query.bias', 'bert.encoder.layer.11.output.LayerNorm.weight', 'bert.encoder.layer.11.output.LayerNorm.bias', 'bert.encoder.layer.2.attention.output.dense.weight', 'bert.encoder.layer.5.intermediate.dense.weight', 'bert.encoder.layer.7.attention.output.LayerNorm.weight', 'bert.encoder.layer.9.output.LayerNorm.bias', 'bert.encoder.layer.8.intermediate.dense.weight', 'bert.encoder.layer.3.attention.output.LayerNorm.bias', 'bert.encoder.layer.2.attention.self.query.bias', 'bert.encoder.layer.6.attention.output.LayerNorm.weight', 'bert.encoder.layer.6.intermediate.dense.bias', 'bert.encoder.layer.8.intermediate.dense.bias', 'bert.encoder.layer.10.attention.self.value.bias', 'bert.encoder.layer.11.attention.output.LayerNorm.bias', 'bert.encoder.layer.3.intermediate.dense.bias', 'bert.encoder.layer.6.attention.self.value.bias', 'cls.seq_relationship.bias', 'bert.encoder.layer.8.attention.self.query.weight', 'bert.encoder.layer.11.attention.self.key.weight', 'bert.encoder.layer.6.attention.output.LayerNorm.bias', 'bert.encoder.layer.6.attention.self.query.bias', 'bert.encoder.layer.10.output.LayerNorm.bias', 'bert.encoder.layer.5.output.LayerNorm.bias', 'bert.encoder.layer.5.attention.output.dense.weight', 'bert.encoder.layer.7.output.dense.weight', 'bert.encoder.layer.9.attention.self.value.bias', 'bert.encoder.layer.8.attention.output.dense.weight', 'bert.encoder.layer.3.intermediate.dense.weight', 'bert.encoder.layer.6.attention.output.dense.weight', 'bert.encoder.layer.5.attention.output.LayerNorm.bias', 'cls.predictions.transform.dense.bias', 'bert.encoder.layer.7.attention.self.query.weight', 'bert.encoder.layer.11.attention.self.value.bias', 'bert.encoder.layer.4.attention.self.query.weight', 'bert.encoder.layer.6.output.dense.weight', 'bert.encoder.layer.4.attention.output.LayerNorm.bias', 'bert.encoder.layer.3.attention.self.query.bias', 'bert.encoder.layer.7.intermediate.dense.weight', 'bert.encoder.layer.4.attention.self.key.weight', 'bert.encoder.layer.5.output.dense.weight', 'bert.encoder.layer.10.attention.output.LayerNorm.bias', 'bert.encoder.layer.4.output.LayerNorm.bias', 'bert.encoder.layer.6.attention.self.key.bias', 'bert.encoder.layer.7.output.dense.bias', 'bert.encoder.layer.2.intermediate.dense.bias', 'bert.encoder.layer.7.attention.output.LayerNorm.bias', 'bert.encoder.layer.9.intermediate.dense.bias', 'bert.encoder.layer.10.output.LayerNorm.weight', 'bert.encoder.layer.3.output.LayerNorm.weight', 'bert.encoder.layer.2.attention.self.value.weight', 'bert.encoder.layer.5.output.dense.bias', 'bert.encoder.layer.3.attention.output.LayerNorm.weight', 'bert.encoder.layer.4.output.dense.weight', 'bert.encoder.layer.5.attention.self.value.weight', 'bert.encoder.layer.8.attention.self.value.bias', 'bert.encoder.layer.2.intermediate.dense.weight', 'bert.encoder.layer.8.attention.self.key.weight', 'bert.encoder.layer.5.attention.self.key.bias', 'bert.encoder.layer.10.attention.self.value.weight', 'bert.encoder.layer.4.attention.self.query.bias', 'bert.encoder.layer.9.attention.output.dense.bias', 'bert.encoder.layer.7.attention.self.key.weight', 'bert.encoder.layer.2.attention.self.value.bias', 'bert.encoder.layer.3.attention.self.query.weight', 'bert.encoder.layer.6.output.LayerNorm.bias', 'bert.encoder.layer.3.output.dense.weight', 'bert.encoder.layer.9.intermediate.dense.weight', 'bert.encoder.layer.3.attention.self.key.weight', 'bert.encoder.layer.10.attention.self.query.weight', 'cls.predictions.transform.LayerNorm.weight', 'bert.encoder.layer.5.attention.output.dense.bias', 'bert.encoder.layer.8.output.dense.weight', 'bert.encoder.layer.3.attention.output.dense.bias', 'bert.encoder.layer.10.attention.output.dense.bias', 'bert.encoder.layer.11.attention.self.query.bias', 'bert.encoder.layer.9.attention.output.LayerNorm.bias', 'bert.encoder.layer.10.attention.self.key.weight', 'bert.encoder.layer.10.intermediate.dense.bias', 'bert.encoder.layer.4.attention.output.dense.bias', 'bert.encoder.layer.8.attention.self.query.bias', 'bert.encoder.layer.4.output.dense.bias', 'bert.encoder.layer.11.intermediate.dense.bias', 'bert.encoder.layer.10.output.dense.bias', 'bert.encoder.layer.5.attention.self.query.weight', 'bert.encoder.layer.10.attention.self.key.bias', 'bert.encoder.layer.7.attention.self.value.weight', 'bert.encoder.layer.7.output.LayerNorm.bias', 'cls.predictions.transform.dense.weight', 'bert.encoder.layer.2.attention.output.LayerNorm.bias', 'bert.encoder.layer.7.intermediate.dense.bias', 'bert.encoder.layer.5.attention.self.key.weight', 'bert.encoder.layer.11.attention.self.value.weight', 'bert.encoder.layer.9.attention.self.query.weight', 'bert.encoder.layer.4.attention.self.key.bias', 'bert.encoder.layer.6.output.LayerNorm.weight', 'bert.encoder.layer.4.output.LayerNorm.weight', 'bert.encoder.layer.4.attention.output.LayerNorm.weight', 'bert.encoder.layer.9.attention.self.key.weight', 'bert.encoder.layer.11.attention.output.dense.weight', 'bert.encoder.layer.2.output.LayerNorm.bias', 'bert.encoder.layer.6.attention.self.key.weight', 'bert.encoder.layer.2.attention.self.key.weight', 'bert.encoder.layer.4.attention.self.value.bias', 'bert.encoder.layer.5.attention.output.LayerNorm.weight', 'bert.encoder.layer.9.attention.self.query.bias', 'bert.encoder.layer.3.attention.self.key.bias', 'bert.encoder.layer.2.output.dense.bias', 'bert.encoder.layer.9.output.dense.weight', 'bert.encoder.layer.4.intermediate.dense.bias', 'bert.encoder.layer.2.attention.output.LayerNorm.weight', 'bert.encoder.layer.2.output.LayerNorm.weight', 'bert.encoder.layer.8.output.dense.bias', 'bert.encoder.layer.2.attention.self.query.weight', 'bert.encoder.layer.9.attention.self.value.weight', 'bert.encoder.layer.10.attention.output.dense.weight', 'bert.encoder.layer.4.attention.self.value.weight', 'bert.encoder.layer.7.attention.self.key.bias', 'bert.encoder.layer.7.attention.output.dense.weight', 'bert.encoder.layer.2.attention.output.dense.bias', 'bert.encoder.layer.7.output.LayerNorm.weight', 'bert.encoder.layer.11.attention.output.dense.bias', 'bert.encoder.layer.6.output.dense.bias', 'bert.encoder.layer.11.attention.output.LayerNorm.weight', 'bert.encoder.layer.11.intermediate.dense.weight', 'bert.encoder.layer.7.attention.self.value.bias', 'bert.encoder.layer.10.intermediate.dense.weight', 'bert.encoder.layer.8.attention.output.dense.bias', 'cls.predictions.decoder.weight', 'bert.encoder.layer.8.attention.output.LayerNorm.bias', 'bert.encoder.layer.10.attention.self.query.bias', 'cls.predictions.bias', 'bert.encoder.layer.8.output.LayerNorm.weight', 'bert.encoder.layer.3.output.dense.bias', 'bert.encoder.layer.10.output.dense.weight', 'cls.seq_relationship.weight', 'bert.encoder.layer.6.attention.self.query.weight', 'bert.encoder.layer.11.attention.self.query.weight', 'bert.encoder.layer.7.attention.output.dense.bias', 'bert.encoder.layer.11.output.dense.bias', 'bert.encoder.layer.3.output.LayerNorm.bias', 'bert.encoder.layer.8.attention.self.value.weight', 'bert.encoder.layer.3.attention.output.dense.weight', 'bert.encoder.layer.8.output.LayerNorm.bias', 'bert.encoder.layer.6.intermediate.dense.weight', 'bert.encoder.layer.3.attention.self.value.bias', 'bert.encoder.layer.6.attention.self.value.weight', 'cls.predictions.transform.LayerNorm.bias']\n",
                        "- This IS expected if you are initializing BertForSequenceClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
                        "- This IS NOT expected if you are initializing BertForSequenceClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n",
                        "Some weights of BertForSequenceClassification were not initialized from the model checkpoint at ./bert-roberta and are newly initialized: ['classifier.weight', 'classifier.bias']\n",
                        "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n",
                        "Some weights of the model checkpoint at ./bert-roberta were not used when initializing BertForSequenceClassification: ['bert.encoder.layer.9.attention.output.dense.weight', 'bert.encoder.layer.10.attention.output.LayerNorm.weight', 'bert.encoder.layer.2.output.dense.weight', 'bert.encoder.layer.9.output.dense.bias', 'bert.encoder.layer.5.attention.self.query.bias', 'bert.encoder.layer.3.attention.self.value.weight', 'bert.encoder.layer.8.attention.output.LayerNorm.weight', 'bert.encoder.layer.5.intermediate.dense.bias', 'bert.encoder.layer.9.output.LayerNorm.weight', 'bert.encoder.layer.2.attention.self.key.bias', 'bert.encoder.layer.11.attention.self.key.bias', 'bert.encoder.layer.8.attention.self.key.bias', 'bert.encoder.layer.5.output.LayerNorm.weight', 'bert.encoder.layer.4.intermediate.dense.weight', 'bert.encoder.layer.9.attention.self.key.bias', 'bert.encoder.layer.9.attention.output.LayerNorm.weight', 'bert.encoder.layer.5.attention.self.value.bias', 'bert.encoder.layer.6.attention.output.dense.bias', 'bert.encoder.layer.11.output.dense.weight', 'bert.encoder.layer.4.attention.output.dense.weight', 'bert.encoder.layer.7.attention.self.query.bias', 'bert.encoder.layer.11.output.LayerNorm.weight', 'bert.encoder.layer.11.output.LayerNorm.bias', 'bert.encoder.layer.2.attention.output.dense.weight', 'bert.encoder.layer.5.intermediate.dense.weight', 'bert.encoder.layer.7.attention.output.LayerNorm.weight', 'bert.encoder.layer.9.output.LayerNorm.bias', 'bert.encoder.layer.8.intermediate.dense.weight', 'bert.encoder.layer.3.attention.output.LayerNorm.bias', 'bert.encoder.layer.2.attention.self.query.bias', 'bert.encoder.layer.6.attention.output.LayerNorm.weight', 'bert.encoder.layer.6.intermediate.dense.bias', 'bert.encoder.layer.8.intermediate.dense.bias', 'bert.encoder.layer.10.attention.self.value.bias', 'bert.encoder.layer.11.attention.output.LayerNorm.bias', 'bert.encoder.layer.3.intermediate.dense.bias', 'bert.encoder.layer.6.attention.self.value.bias', 'cls.seq_relationship.bias', 'bert.encoder.layer.8.attention.self.query.weight', 'bert.encoder.layer.11.attention.self.key.weight', 'bert.encoder.layer.6.attention.output.LayerNorm.bias', 'bert.encoder.layer.6.attention.self.query.bias', 'bert.encoder.layer.10.output.LayerNorm.bias', 'bert.encoder.layer.5.output.LayerNorm.bias', 'bert.encoder.layer.5.attention.output.dense.weight', 'bert.encoder.layer.7.output.dense.weight', 'bert.encoder.layer.9.attention.self.value.bias', 'bert.encoder.layer.8.attention.output.dense.weight', 'bert.encoder.layer.3.intermediate.dense.weight', 'bert.encoder.layer.6.attention.output.dense.weight', 'bert.encoder.layer.5.attention.output.LayerNorm.bias', 'cls.predictions.transform.dense.bias', 'bert.encoder.layer.7.attention.self.query.weight', 'bert.encoder.layer.11.attention.self.value.bias', 'bert.encoder.layer.4.attention.self.query.weight', 'bert.encoder.layer.6.output.dense.weight', 'bert.encoder.layer.4.attention.output.LayerNorm.bias', 'bert.encoder.layer.3.attention.self.query.bias', 'bert.encoder.layer.7.intermediate.dense.weight', 'bert.encoder.layer.4.attention.self.key.weight', 'bert.encoder.layer.5.output.dense.weight', 'bert.encoder.layer.10.attention.output.LayerNorm.bias', 'bert.encoder.layer.4.output.LayerNorm.bias', 'bert.encoder.layer.6.attention.self.key.bias', 'bert.encoder.layer.7.output.dense.bias', 'bert.encoder.layer.2.intermediate.dense.bias', 'bert.encoder.layer.7.attention.output.LayerNorm.bias', 'bert.encoder.layer.9.intermediate.dense.bias', 'bert.encoder.layer.10.output.LayerNorm.weight', 'bert.encoder.layer.3.output.LayerNorm.weight', 'bert.encoder.layer.2.attention.self.value.weight', 'bert.encoder.layer.5.output.dense.bias', 'bert.encoder.layer.3.attention.output.LayerNorm.weight', 'bert.encoder.layer.4.output.dense.weight', 'bert.encoder.layer.5.attention.self.value.weight', 'bert.encoder.layer.8.attention.self.value.bias', 'bert.encoder.layer.2.intermediate.dense.weight', 'bert.encoder.layer.8.attention.self.key.weight', 'bert.encoder.layer.5.attention.self.key.bias', 'bert.encoder.layer.10.attention.self.value.weight', 'bert.encoder.layer.4.attention.self.query.bias', 'bert.encoder.layer.9.attention.output.dense.bias', 'bert.encoder.layer.7.attention.self.key.weight', 'bert.encoder.layer.2.attention.self.value.bias', 'bert.encoder.layer.3.attention.self.query.weight', 'bert.encoder.layer.6.output.LayerNorm.bias', 'bert.encoder.layer.3.output.dense.weight', 'bert.encoder.layer.9.intermediate.dense.weight', 'bert.encoder.layer.3.attention.self.key.weight', 'bert.encoder.layer.10.attention.self.query.weight', 'cls.predictions.transform.LayerNorm.weight', 'bert.encoder.layer.5.attention.output.dense.bias', 'bert.encoder.layer.8.output.dense.weight', 'bert.encoder.layer.3.attention.output.dense.bias', 'bert.encoder.layer.10.attention.output.dense.bias', 'bert.encoder.layer.11.attention.self.query.bias', 'bert.encoder.layer.9.attention.output.LayerNorm.bias', 'bert.encoder.layer.10.attention.self.key.weight', 'bert.encoder.layer.10.intermediate.dense.bias', 'bert.encoder.layer.4.attention.output.dense.bias', 'bert.encoder.layer.8.attention.self.query.bias', 'bert.encoder.layer.4.output.dense.bias', 'bert.encoder.layer.11.intermediate.dense.bias', 'bert.encoder.layer.10.output.dense.bias', 'bert.encoder.layer.5.attention.self.query.weight', 'bert.encoder.layer.10.attention.self.key.bias', 'bert.encoder.layer.7.attention.self.value.weight', 'bert.encoder.layer.7.output.LayerNorm.bias', 'cls.predictions.transform.dense.weight', 'bert.encoder.layer.2.attention.output.LayerNorm.bias', 'bert.encoder.layer.7.intermediate.dense.bias', 'bert.encoder.layer.5.attention.self.key.weight', 'bert.encoder.layer.11.attention.self.value.weight', 'bert.encoder.layer.9.attention.self.query.weight', 'bert.encoder.layer.4.attention.self.key.bias', 'bert.encoder.layer.6.output.LayerNorm.weight', 'bert.encoder.layer.4.output.LayerNorm.weight', 'bert.encoder.layer.4.attention.output.LayerNorm.weight', 'bert.encoder.layer.9.attention.self.key.weight', 'bert.encoder.layer.11.attention.output.dense.weight', 'bert.encoder.layer.2.output.LayerNorm.bias', 'bert.encoder.layer.6.attention.self.key.weight', 'bert.encoder.layer.2.attention.self.key.weight', 'bert.encoder.layer.4.attention.self.value.bias', 'bert.encoder.layer.5.attention.output.LayerNorm.weight', 'bert.encoder.layer.9.attention.self.query.bias', 'bert.encoder.layer.3.attention.self.key.bias', 'bert.encoder.layer.2.output.dense.bias', 'bert.encoder.layer.9.output.dense.weight', 'bert.encoder.layer.4.intermediate.dense.bias', 'bert.encoder.layer.2.attention.output.LayerNorm.weight', 'bert.encoder.layer.2.output.LayerNorm.weight', 'bert.encoder.layer.8.output.dense.bias', 'bert.encoder.layer.2.attention.self.query.weight', 'bert.encoder.layer.9.attention.self.value.weight', 'bert.encoder.layer.10.attention.output.dense.weight', 'bert.encoder.layer.4.attention.self.value.weight', 'bert.encoder.layer.7.attention.self.key.bias', 'bert.encoder.layer.7.attention.output.dense.weight', 'bert.encoder.layer.2.attention.output.dense.bias', 'bert.encoder.layer.7.output.LayerNorm.weight', 'bert.encoder.layer.11.attention.output.dense.bias', 'bert.encoder.layer.6.output.dense.bias', 'bert.encoder.layer.11.attention.output.LayerNorm.weight', 'bert.encoder.layer.11.intermediate.dense.weight', 'bert.encoder.layer.7.attention.self.value.bias', 'bert.encoder.layer.10.intermediate.dense.weight', 'bert.encoder.layer.8.attention.output.dense.bias', 'cls.predictions.decoder.weight', 'bert.encoder.layer.8.attention.output.LayerNorm.bias', 'bert.encoder.layer.10.attention.self.query.bias', 'cls.predictions.bias', 'bert.encoder.layer.8.output.LayerNorm.weight', 'bert.encoder.layer.3.output.dense.bias', 'bert.encoder.layer.10.output.dense.weight', 'cls.seq_relationship.weight', 'bert.encoder.layer.6.attention.self.query.weight', 'bert.encoder.layer.11.attention.self.query.weight', 'bert.encoder.layer.7.attention.output.dense.bias', 'bert.encoder.layer.11.output.dense.bias', 'bert.encoder.layer.3.output.LayerNorm.bias', 'bert.encoder.layer.8.attention.self.value.weight', 'bert.encoder.layer.3.attention.output.dense.weight', 'bert.encoder.layer.8.output.LayerNorm.bias', 'bert.encoder.layer.6.intermediate.dense.weight', 'bert.encoder.layer.3.attention.self.value.bias', 'bert.encoder.layer.6.attention.self.value.weight', 'cls.predictions.transform.LayerNorm.bias']\n",
                        "- This IS expected if you are initializing BertForSequenceClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
                        "- This IS NOT expected if you are initializing BertForSequenceClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n",
                        "Some weights of BertForSequenceClassification were not initialized from the model checkpoint at ./bert-roberta and are newly initialized: ['classifier.weight', 'classifier.bias']\n",
                        "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n",
                        "Some weights of the model checkpoint at ./bert-roberta were not used when initializing BertModel: ['cls.predictions.bias', 'cls.seq_relationship.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.decoder.weight', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.transform.LayerNorm.weight']\n",
                        "- This IS expected if you are initializing BertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n",
                        "- This IS NOT expected if you are initializing BertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n"
                    ]
                },
                {
                    "data": {
                        "text/plain": [
                            "Model(\n",
                            "  (rnn): GRU(768, 768, batch_first=True)\n",
                            "  (fc): Linear(in_features=768, out_features=8, bias=True)\n",
                            "  (pretrained): BertModel(\n",
                            "    (embeddings): BertEmbeddings(\n",
                            "      (word_embeddings): Embedding(21128, 768, padding_idx=0)\n",
                            "      (position_embeddings): Embedding(512, 768)\n",
                            "      (token_type_embeddings): Embedding(2, 768)\n",
                            "      (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)\n",
                            "      (dropout): Dropout(p=0.1, inplace=False)\n",
                            "    )\n",
                            "    (encoder): BertEncoder(\n",
                            "      (layer): ModuleList(\n",
                            "        (0-11): 12 x BertLayer(\n",
                            "          (attention): BertAttention(\n",
                            "            (self): BertSelfAttention(\n",
                            "              (query): Linear(in_features=768, out_features=768, bias=True)\n",
                            "              (key): Linear(in_features=768, out_features=768, bias=True)\n",
                            "              (value): Linear(in_features=768, out_features=768, bias=True)\n",
                            "              (dropout): Dropout(p=0.1, inplace=False)\n",
                            "            )\n",
                            "            (output): BertSelfOutput(\n",
                            "              (dense): Linear(in_features=768, out_features=768, bias=True)\n",
                            "              (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)\n",
                            "              (dropout): Dropout(p=0.1, inplace=False)\n",
                            "            )\n",
                            "          )\n",
                            "          (intermediate): BertIntermediate(\n",
                            "            (dense): Linear(in_features=768, out_features=3072, bias=True)\n",
                            "            (intermediate_act_fn): GELUActivation()\n",
                            "          )\n",
                            "          (output): BertOutput(\n",
                            "            (dense): Linear(in_features=3072, out_features=768, bias=True)\n",
                            "            (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)\n",
                            "            (dropout): Dropout(p=0.1, inplace=False)\n",
                            "          )\n",
                            "        )\n",
                            "      )\n",
                            "    )\n",
                            "    (pooler): BertPooler(\n",
                            "      (dense): Linear(in_features=768, out_features=768, bias=True)\n",
                            "      (activation): Tanh()\n",
                            "    )\n",
                            "  )\n",
                            ")"
                        ]
                    },
                    "execution_count": 1,
                    "metadata": {},
                    "output_type": "execute_result"
                }
            ],
            "source": [
                "from transformers import AutoTokenizer, AutoModel, BertTokenizer, BertForSequenceClassification, BertConfig\n",
                "import torch\n",
                "import re\n",
                "from collections import OrderedDict\n",
                "import numpy as np\n",
                "import json\n",
                "import datetime\n",
                "\n",
                "# 加载分类器 model1 用于语句分类  | model2 用于岗位匹配\n",
                "# model_name = 'hfl/chinese-roberta-wwm-ext'\n",
                "model_name = './bert-roberta'\n",
                "tokenizer1 = BertTokenizer.from_pretrained(\n",
                "    model_name)\n",
                "\n",
                "# 使用时将模型放在文件夹下\n",
                "config1 = BertConfig.from_pretrained(model_name)\n",
                "config1.num_hidden_layers = 2\n",
                "config1.num_labels = 7\n",
                "model1 = BertForSequenceClassification.from_pretrained(\n",
                "    model_name, config=config1)\n",
                "model1.load_state_dict(torch.load('Roberta.pt'))\n",
                "model1.eval()\n",
                "\n",
                "tokenizer2 = BertTokenizer.from_pretrained(model_name)\n",
                "config2 = BertConfig.from_pretrained(model_name)\n",
                "config2.num_hidden_layers = 2\n",
                "config2.num_labels = 11\n",
                "model2 = BertForSequenceClassification.from_pretrained(\n",
                "    model_name, config=config2)\n",
                "model2.load_state_dict(torch.load('Job.pt'))\n",
                "model2.eval()\n",
                "\n",
                "\n",
                "# 加载NER\n",
                "tokenizer3 = AutoTokenizer.from_pretrained(model_name)\n",
                "pretrained = AutoModel.from_pretrained(model_name)\n",
                "\n",
                "\n",
                "# 定义下游模型\n",
                "class Model(torch.nn.Module):\n",
                "    def __init__(self):\n",
                "        super().__init__()\n",
                "        self.tuning = False\n",
                "        self.pretrained = None\n",
                "\n",
                "        self.rnn = torch.nn.GRU(768, 768, batch_first=True)\n",
                "        self.fc = torch.nn.Linear(768, 8)\n",
                "\n",
                "    def forward(self, inputs):\n",
                "        if self.tuning:\n",
                "            out = self.pretrained(**inputs).last_hidden_state\n",
                "        else:\n",
                "            with torch.no_grad():\n",
                "                out = pretrained(**inputs).last_hidden_state\n",
                "        out, _ = self.rnn(out)\n",
                "        out = self.fc(out).softmax(dim=2)\n",
                "        return out\n",
                "\n",
                "\n",
                "model3 = torch.load('Ner.pt')\n",
                "model3.eval()\n",
                "model3.to('cpu')\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 2,
            "metadata": {},
            "outputs": [],
            "source": [
                "def label_predict(sentence):\n",
                "    encoding = tokenizer1.encode_plus(\n",
                "        sentence,\n",
                "        add_special_tokens=True,\n",
                "        padding='max_length',\n",
                "        truncation=True,\n",
                "        max_length=128,\n",
                "        return_tensors='pt'\n",
                "    )\n",
                "\n",
                "    input_ids = encoding['input_ids'].squeeze()\n",
                "    attention_mask = encoding['attention_mask'].squeeze()\n",
                "    with torch.no_grad():\n",
                "        outputs = model1(input_ids.unsqueeze(\n",
                "            0), attention_mask=attention_mask.unsqueeze(0))\n",
                "        logits = outputs.logits\n",
                "\n",
                "    _, predicted_label = torch.max(logits, dim=1)\n",
                "\n",
                "    return predicted_label.item()\n",
                "\n",
                "\n",
                "def job_predict(sentence):\n",
                "    encoding = tokenizer2.encode_plus(\n",
                "        sentence,\n",
                "        add_special_tokens=True,\n",
                "        padding='max_length',\n",
                "        truncation=True,\n",
                "        max_length=512,\n",
                "        return_tensors='pt'\n",
                "    )\n",
                "\n",
                "    input_ids = encoding['input_ids'].squeeze()\n",
                "    attention_mask = encoding['attention_mask'].squeeze()\n",
                "    with torch.no_grad():\n",
                "        outputs = model2(input_ids.unsqueeze(\n",
                "            0), attention_mask=attention_mask.unsqueeze(0))\n",
                "        logits = outputs.logits\n",
                "\n",
                "    # 获取预测的标签和对应的预测概率值\n",
                "    predicted_probs = torch.softmax(logits, dim=1)\n",
                "    # predicted_label = torch.argmax(predicted_probs, dim=1)\n",
                "\n",
                "    predicted_labels = {}\n",
                "    for index, value in enumerate(predicted_probs.squeeze().tolist()):\n",
                "        # 设置概率阈值 超过该阈值的可以作为候选项 此处 0.1 较合理\n",
                "        if value >= 0.1:\n",
                "            predicted_labels[index] = value\n",
                "    \n",
                "    return dict(sorted(predicted_labels.items(), key=lambda x: x[1], reverse=True))\n",
                "\n",
                "\n",
                "def ner_predict(sentence):\n",
                "    if len(sentence) > 500:\n",
                "        return [[] for _ in range(3)]\n",
                "    inputs = tokenizer3.encode_plus([sentence],\n",
                "                                    truncation=True,\n",
                "                                    padding=True,\n",
                "                                    return_tensors='pt',\n",
                "                                    is_split_into_words=True)\n",
                "    with torch.no_grad():\n",
                "        outputs = model3(inputs)\n",
                "    preds = outputs.argmax(dim=2)[0]\n",
                "    result = ''\n",
                "    res = [[] for _ in range(3)]\n",
                "    tmp = ''\n",
                "    current_flag = -1\n",
                "\n",
                "    for i in range(len(preds)):\n",
                "        if inputs['attention_mask'][0][i] == 1:\n",
                "            result += tokenizer3.decode(inputs['input_ids'][0][i])+' '\n",
                "            result += str(preds[i].item())+' '\n",
                "            num = preds[i].item()\n",
                "            # num 不为0和7和#表示该词为关键词\n",
                "            if (num != 0 and num != 7 and num != '#'):\n",
                "                # 关键词开始为奇数\n",
                "                if (num & 1):\n",
                "                    # 将形如 广5东6广5州6 拆成两个词\n",
                "                    if (len(tmp) > 1):\n",
                "                        res[(current_flag-1)//2].append(tmp)\n",
                "                        tmp = ''\n",
                "                    current_flag = num\n",
                "                    tmp += tokenizer3.decode(inputs['input_ids'][0][i])\n",
                "\n",
                "                    # 防止形如 X4X4 出现\n",
                "                elif (num & 1 == 0 and current_flag != -1):\n",
                "                    tmp += tokenizer3.decode(inputs['input_ids'][0][i])\n",
                "            else:\n",
                "                if (len(tmp) > 1):\n",
                "                    # current_flag 1对应姓名下标0，3对应组织下表1，5对应地点下表2\n",
                "                    res[(current_flag-1)//2].append(tmp)\n",
                "                    tmp = ''\n",
                "                    current_flag = -1\n",
                "    return res\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 3,
            "metadata": {},
            "outputs": [],
            "source": [
                "import info\n",
                "\n",
                "\n",
                "def re_basedata(basic_data, data):\n",
                "    if basic_data['tel'] == '':\n",
                "        tel = re.findall(info.tel_pattern(), data)\n",
                "        if tel:\n",
                "            basic_data['tel'] = tel[0]\n",
                "    if basic_data['email'] == '':\n",
                "        email = re.findall(info.email_pattern(), data)\n",
                "        if email:\n",
                "            basic_data['email'] = email[0]\n",
                "    if basic_data['age'] == 0:\n",
                "        age = re.search(info.age_pattern(), data)\n",
                "        if age:\n",
                "            if age.group(1):\n",
                "                basic_data['age'] = int(age.group(1))\n",
                "            else:\n",
                "                basic_data['age'] = int(age.group(2))\n",
                "    if basic_data['birth'] == '':\n",
                "        birth = re.search(info.birth_pattern(), data)\n",
                "        if birth:\n",
                "            basic_data['birth'] = birth.group()\n",
                "            basic_data['age'] = 2023 - int(basic_data['birth'][:4])+1\n",
                "    edu = re.findall(info.edu_pattern(), data)\n",
                "    if edu:\n",
                "        for e in edu:\n",
                "            # 找到的学历大于当前的学历就更新\n",
                "            if info.edu_map()[e] > info.edu_map()[basic_data['edu']]:\n",
                "                basic_data['edu'] = e\n",
                "    return basic_data\n",
                "\n",
                "\n",
                "def handle_basedata(data, basic_data, total_data):\n",
                "    # 合并语句 优化Ner次数\n",
                "    for data in list(OrderedDict.fromkeys(data[0])):\n",
                "        # 先跑NER 选出姓名 地点 学历\n",
                "        output_prediction = ner_predict(data)\n",
                "        if len(output_prediction[0]) and basic_data['name'] == '' and re.match(info.chinese_str(), output_prediction[0][0]):\n",
                "            basic_data['name'] = output_prediction[0][0]\n",
                "        elif len(output_prediction[1]):\n",
                "            basic_data['college'].extend(output_prediction[1])\n",
                "        elif len(output_prediction[2]):\n",
                "            basic_data['loc'].extend(output_prediction[2])\n",
                "        # 再跑正则匹配更新label\n",
                "        basic_data = re_basedata(basic_data, data)\n",
                "\n",
                "    fixed_college = []\n",
                "    for x in basic_data['college']:\n",
                "        for keyword in info.college_endword():\n",
                "            keyword_position = x.find(keyword)\n",
                "            if keyword_position != -1:\n",
                "                fixed_college.append(x[:keyword_position + len(keyword)])\n",
                "                # 注意这里内循环需要是 keyword 并且必须 break 防止识别两次 优先级见 info\n",
                "                break\n",
                "    basic_data['college'] = list(OrderedDict.fromkeys(fixed_college))\n",
                "    basic_data['loc'] = list(OrderedDict.fromkeys(basic_data['loc']))[:2]\n",
                "\n",
                "    # 给学校加tag\n",
                "    if np.intersect1d(basic_data['college'], info.college985()).size > 0:\n",
                "        total_data['tag']['edu_tag'].append('985')\n",
                "        total_data['score'] += info.score_map()['985']\n",
                "    elif np.intersect1d(basic_data['college'], info.college211()).size > 0:\n",
                "        total_data['tag']['edu_tag'].append('211')\n",
                "        total_data['score'] += info.score_map()['211']\n",
                "\n",
                "    # 给籍贯加tag\n",
                "    if len(basic_data['loc']) > 0:\n",
                "        loc_pattern = '|'.join(info.province())\n",
                "        for loc in basic_data['loc']:\n",
                "            matches = re.findall(loc_pattern, loc)\n",
                "            if matches:\n",
                "                total_data['tag']['loc_tag'] = matches[0]\n",
                "                break\n",
                "\n",
                "    # 最高学历加tag\n",
                "    if len(basic_data['edu']) > 0:\n",
                "        total_data['tag']['edu_tag'].append(basic_data['edu'])\n",
                "        total_data['score'] += info.score_map()[basic_data['edu']]\n",
                "\n",
                "    # 删除空字段\n",
                "    key_to_del = []\n",
                "    for key, value in basic_data.items():\n",
                "        if value == '' or value == [] or value == 0:\n",
                "            key_to_del.append(key)\n",
                "    for key in key_to_del:\n",
                "        del basic_data[key]\n",
                "\n",
                "\n",
                "def handle_job_obj(total_data):\n",
                "    raw_jobs = total_data['job_obj']\n",
                "    fixed_jobs = []\n",
                "    # 找首个个特殊符号 直接截断后半段加入答案 没找到符号直接加入答案\n",
                "    for job in raw_jobs:\n",
                "        pos = job.find(\":\")\n",
                "        if pos == -1:\n",
                "            pos = job.find(\"/\")\n",
                "        if pos == -1:\n",
                "            pos = job.find(\"：\")\n",
                "        if pos == -1:\n",
                "            fixed_jobs.append(job.replace(\" \", \"\"))\n",
                "        else:\n",
                "            fixed_jobs.append(job[pos+1:].replace(\" \", \"\"))\n",
                "    fixed_jobs = list(OrderedDict.fromkeys(fixed_jobs))\n",
                "    total_data['job_obj'] = fixed_jobs\n",
                "\n",
                "\n",
                "def calculate_date_interval(date1, date2):\n",
                "    date1_obj = datetime.datetime.strptime(date1, \"%Y.%m\")\n",
                "    date2_obj = datetime.datetime.strptime(date2, \"%Y.%m\")\n",
                "    diff = date2_obj - date1_obj\n",
                "    years = diff.days // 365\n",
                "    months = (diff.days % 365) // 30\n",
                "    return years, months\n",
                "\n",
                "\n",
                "def re_date(date):\n",
                "    date = date.replace(\"年\", \".\").replace(\"月\", \"\")\n",
                "    if date[-1:] == '年':\n",
                "        date = date[:-1]\n",
                "    if '.' not in date:\n",
                "        date = date + '.01'\n",
                "    return date\n",
                "\n",
                "\n",
                "def handle_experience(total_data):\n",
                "    company = []\n",
                "    year_interval = 0\n",
                "    month_interval = 0\n",
                "    for exp in total_data['experience']:\n",
                "        # 跑NER找出所有工作单位\n",
                "        output_prediction = ner_predict(exp)\n",
                "        company.extend(output_prediction[1])\n",
                "        # 计算工作年限\n",
                "        matches = re.findall(info.work_time(), exp)\n",
                "        if matches:\n",
                "            for match in matches:\n",
                "                date1 = re_date(match[0])\n",
                "                date2 = '2023.04' if match[1] == '今' or match[1] == '至今' else re_date(\n",
                "                    match[1])\n",
                "                try:\n",
                "                    years, months = calculate_date_interval(date1, date2)\n",
                "                    if years >= 0:\n",
                "                        year_interval += years\n",
                "                        month_interval += months\n",
                "                except Exception as e:\n",
                "                    print(e)\n",
                "\n",
                "        year_interval += month_interval // 12\n",
                "        month_interval %= 12\n",
                "\n",
                "    # 受限于Ner的准确性 仅在自定义下的关键字下识别\n",
                "    # FIXME 择优选择下面两种之一\n",
                "    # fixed_company = []\n",
                "    # for x in company:\n",
                "    #     for keyword in info.college_endword():\n",
                "    #         keyword_position = x.find(keyword)\n",
                "    #         if keyword_position != -1 and x[:keyword_position+len(keyword)] != keyword:\n",
                "    #             fixed_company.append(x[:keyword_position+len(keyword)])\n",
                "    fixed_company = [x for keyword in info.company_endword()\n",
                "                     for x in company if x.endswith(keyword) and x != keyword]\n",
                "    fixed_company = list(OrderedDict.fromkeys(fixed_company))\n",
                "    total_data['tag']['experience_tag'].extend(fixed_company)\n",
                "    if year_interval < 60 and year_interval >= 0:\n",
                "        total_data['tag']['total_work_time'] = year_interval if month_interval == 0 else year_interval + 1\n",
                "    else:\n",
                "        total_data['tag']['total_work_time'] = 0\n",
                "    # 工作经验分值计算 工作单位和工作年限权重为 1.5\n",
                "    total_data['score'] += 1.2 * \\\n",
                "        len(fixed_company) + 0.1 * (year_interval * 12 + month_interval)\n",
                "\n",
                "\n",
                "def handle_ability(total_data):\n",
                "    # 提前判断是否已经找到了 优化一下性能\n",
                "    CET6_flag, CET4_flag, Photoshop_flag, Office_flag, NCRE_flag = False, False, False, False, False\n",
                "    CET6_patter = '|'.join(info.self_ability()[0])\n",
                "    CET4_patter = '|'.join(info.self_ability()[1])\n",
                "    Photoshop_patter = '|'.join(info.self_ability()[2])\n",
                "    Office_patter = '|'.join(info.self_ability()[3])\n",
                "    NCRE_patter = '|'.join(info.self_ability()[4])\n",
                "    # 找出CET Photoshop Office 计算机等级考试 的tag\n",
                "    for item in total_data['ability']:\n",
                "        if CET6_flag == False:\n",
                "            matches = re.findall(CET6_patter, item)\n",
                "            if matches:\n",
                "                total_data['tag']['ability'].append('CET6')\n",
                "                total_data['score'] += info.score_map()['CET6']\n",
                "                CET6_flag = True\n",
                "        if CET6_flag == False and CET4_flag == False:\n",
                "            matches = re.findall(CET4_patter, item)\n",
                "            if matches:\n",
                "                total_data['tag']['ability'].append('CET4')\n",
                "                total_data['score'] += info.score_map()['CET4']\n",
                "                CET4_flag = True\n",
                "        if Photoshop_flag == False:\n",
                "            matches = re.findall(Photoshop_patter, item)\n",
                "            if matches:\n",
                "                total_data['tag']['ability'].append('Photoshop')\n",
                "                Photoshop_flag = True\n",
                "        if Office_flag == False:\n",
                "            matches = re.findall(Office_patter, item)\n",
                "            if matches:\n",
                "                total_data['tag']['ability'].append('Office办公软件')\n",
                "                Office_flag = True\n",
                "        if NCRE_flag == False:\n",
                "            matches = re.findall(NCRE_patter, item)\n",
                "            if matches:\n",
                "                total_data['tag']['ability'].append('计算机等级考试')\n",
                "                total_data['score'] += info.score_map()['NCRE']\n",
                "                NCRE_flag = True\n",
                "\n",
                "\n",
                "def handle_job_fit(total_data):\n",
                "    work_time = total_data['tag']['total_work_time']\n",
                "    edu = total_data['basic_data']['edu'] if 'edu' in total_data['basic_data'] else ''\n",
                "    experience = ''.join(total_data['experience'])\n",
                "    office_ability = True if re.findall(\n",
                "        '|'.join(info.self_ability()[3]), ''.join(total_data['ability'])) else False\n",
                "    age = total_data['basic_data']['age'] if 'age' in total_data['basic_data'] else 0\n",
                "\n",
                "    predicted_labels = job_predict(experience)\n",
                "    for key in predicted_labels:\n",
                "        # 概率比 '暂无' 更小的就没有匹配的必要\n",
                "        if key == 0:\n",
                "            break\n",
                "        if info.edu_map()[edu] >= info.edu_map()[info.job_fit()[key][1]] and work_time >= info.job_fit()[key][2] and (office_ability or not office_ability and info.job_fit()[key][3]) and age >= info.job_fit()[key][4]:\n",
                "            total_data['job_fit'].append(info.job_fit()[key][0])\n",
                "    if len(total_data['job_fit']) == 0:\n",
                "        total_data['job_fit'].append('暂无')\n",
                "\n",
                "\n",
                "def analysis(sentences):\n",
                "    sentences = list(OrderedDict.fromkeys(sentences))\n",
                "    # sequence 为最初分类序列 经过上下文纠正算法得到最终分类结果 data\n",
                "    sequence = []\n",
                "    data = [[] for _ in range(7)]\n",
                "    for s in sentences:\n",
                "        p = label_predict(s)\n",
                "        s = re.sub(r'[\\s\\t]{2,}', ' ', s.strip())\n",
                "        sequence.append([s, p])\n",
                "\n",
                "    # 上下文纠正算法 纠正特殊标签6 这里有两种可能 6,2->6,1 或 6,2->2,2\n",
                "    for i in range(0, len(sequence)-1):\n",
                "        if sequence[i][1] == 6 and sequence[i+1][1] == 2:\n",
                "            job_obj_patter = '|'.join(info.job_obj_keywords())\n",
                "            matches = re.findall(job_obj_patter, sequence[i][0])\n",
                "            if matches:\n",
                "                # 6,2->6,1\n",
                "                sequence[i+1][1] = 1\n",
                "            else:\n",
                "                # 6,2->2,2\n",
                "                sequence[i][1] = 2\n",
                "\n",
                "    # 至此分类完成\n",
                "    for s in sequence:\n",
                "        data[s[1]].append(s[0])\n",
                "\n",
                "    # 对基本信息单独NER+正则匹配\n",
                "    basic_data = {\n",
                "        'name': '',\n",
                "        'birth': '',\n",
                "        'age': 0,\n",
                "        'tel': '',\n",
                "        'email': '',\n",
                "        'college': [],\n",
                "        'loc': [],\n",
                "        'edu': ''\n",
                "    }\n",
                "\n",
                "    tag = {\n",
                "        'edu_tag': [],\n",
                "        'loc_tag': '',\n",
                "        'experience_tag': [],\n",
                "        'ability': [],\n",
                "        'total_work_time': 0\n",
                "    }\n",
                "\n",
                "    total_data = {\n",
                "        'basic_data': basic_data,\n",
                "        'job_obj': data[1],\n",
                "        'experience': data[2],\n",
                "        'award': list(OrderedDict.fromkeys(data[3])),\n",
                "        'ability': list(OrderedDict.fromkeys(data[4])),\n",
                "        'job_fit': [],\n",
                "        'tag': tag,\n",
                "        'score': 0,\n",
                "        'custom_content': {\n",
                "            'money_obj': '',\n",
                "            'self_desc': [],\n",
                "            'self_tag': []\n",
                "        }\n",
                "    }\n",
                "\n",
                "    handle_basedata(data, basic_data, total_data)\n",
                "    handle_job_obj(total_data)\n",
                "    handle_experience(total_data)\n",
                "    handle_ability(total_data)\n",
                "    handle_job_fit(total_data)\n",
                "\n",
                "    # return json.dumps(total_data, ensure_ascii=False)\n",
                "    return total_data\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "import os\n",
                "import docx2txt\n",
                "import tqdm\n",
                "\n",
                "res = {}\n",
                "for i in tqdm.notebook.tqdm(range(101, 301)):\n",
                "    path = f'D:\\暂存\\测试数据及说明\\data\\{i}.docx'\n",
                "    if not os.path.isfile(path):\n",
                "        continue\n",
                "\n",
                "    # 读取Word文档\n",
                "    text = docx2txt.process(path)\n",
                "    lines = text.splitlines()\n",
                "    stripped_lines = [line.strip() for line in lines]\n",
                "    new_list = [x for x in stripped_lines if x]\n",
                "    data = analysis(new_list)\n",
                "    ans = {}\n",
                "    ans['name'] = data['basic_data']['name'] if 'name' in data['basic_data'] else ''\n",
                "    ans['age'] = data['basic_data']['age'] if 'age' in data['basic_data'] else ''\n",
                "    ans['education'] = data['basic_data']['edu'] if 'edu' in data['basic_data'] else ''\n",
                "    ans['school'] = data['basic_data']['college'][0] if 'college' in data['basic_data'] and len(\n",
                "        data['basic_data']['college']) > 0 else ''\n",
                "    ans['work_time'] = data['tag']['total_work_time']\n",
                "    ans['match_position'] = data['job_fit']\n",
                "    res[i] = ans\n",
                "    print(ans)\n",
                "\n",
                "json_data = json.dumps(res, ensure_ascii=False)\n",
                "with open('./res.json', \"w\", encoding='utf-8') as file:\n",
                "    file.write(json_data)\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 4,
            "metadata": {},
            "outputs": [
                {
                    "name": "stderr",
                    "output_type": "stream",
                    "text": [
                        "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n"
                    ]
                },
                {
                    "name": "stdout",
                    "output_type": "stream",
                    "text": [
                        "{'basic_data': {'name': '张吉惟', 'birth': '1998.11', 'age': 26, 'tel': '138 9999 9999', 'email': 'zhangjiwei@163.com', 'college': ['北京师范大学'], 'loc': ['北京', '海淀区'], 'edu': '本科'}, 'job_obj': ['行政管理类'], 'experience': ['2022.3至今\\t部长助理', '北京猫眼机械有限公司', '质管部部长助理.负责票证车间生产质量检查,控制,兼任企业内审员,推行ISO9001:2008及ISO14000体系并年审。', '2021.2-2022.3\\t总经理助理', '北京猫眼国际货运代理有限公司', '根据公司的经营理念和发展战略制定公司各工作岗位的工作目标;负责制定及推进公司员工的培训、绩效、薪酬的管理。', '2020.2-2021.2\\t运营助理', '北京猫眼文化传媒有限公司', '根据目标管理综合考评内容，深入、细致地到所跟踪的各场所了解、掌握情况，帮助和促进各场所提高行政、后勤管理水平。'], 'award': ['2016\\t全国大学生英语竞赛一等奖', '2017\\t国家级一等奖学金'], 'ability': ['EXCEL', 'PPT', 'WORD', 'AI', 'PS', '2018\\t大学英语6级证书（CET-6）'], 'job_fit': ['人力资源管理', '文员'], 'tag': {'edu_tag': ['985', '本科'], 'loc_tag': '北京', 'experience_tag': ['北京猫眼机械有限公司', '北京猫眼国际货运代理有限公司', '北京猫眼文化传媒有限公司'], 'ability': ['Office办公软件', 'Photoshop', 'CET6'], 'total_work_time': 4}, 'score': 27.3, 'custom_content': {'money_obj': '', 'self_desc': [], 'self_tag': []}}\n",
                        "{'basic_data': {'name': '王美珠', 'birth': '1989.05', 'age': 35, 'tel': '13800138000', 'email': 'service@500d.me', 'college': ['湖南师范大学'], 'loc': ['湖北省', '武汉市'], 'edu': '博士'}, 'job_obj': ['市场总监-专注品牌方向'], 'experience': ['2022.09-至今 辉世设计控股集团 副总监', '负责协助集团旗下事业部开展各项工作，制定品牌传播方案；', '结合集团与事业部发展，制定营销策略、广告策略、品牌策略和公关策略，并组织推进执行；', '制定和执行媒体投放计划，跟踪和监督媒体投放效果，进行数据分析与撰写报告；', '负责公司品牌形象和价值提升的持续优化，提高品牌知名度；', '研究行业发展动态，定期进行市场调查,为产品更新提供建议。', '信健设计集团品牌升级发布会', '集团全新品牌logo及VI上线，在多渠道进行了传播；', '企业VIP客户群体逾60人，结合了线上发布、线下体验；', '后续媒体报道持续升温，子品牌罄玉结合代言人罗嘉良制造话题营销，为期3周；', '鼎基设计商业模式发布会', '整场活动以会议+洽谈双重模式进行，首日以介绍鼎基内部平台资源优势，政府背景优势等为主，一对多推介会进行推广普及；', '现场签署地方合作意向书，如：新疆、江西、浙江等优秀企业商户；', '以中国的波尔多为宣传点，主推旗下新疆大型项目，罄玉生态葡萄庄园、沙漠主题俱乐部等，制造营销、品牌热点。', '2021.09-2022.09 鼎基设计有限公司 市场及运营总监', '根据公司发展情况进行战略调整，配合前端销售部门搭建销售渠道；', '研究行业发展动态，定期进行市场调查,为产品更新提供建议；', '负责公司部门(营运、品牌策划)制度规范，负责组织及监管市场部关于对外合作、渠道管理、媒体合作、推广策划以相关工作的落实。', '2020.09-2021.09 宏建设计俱乐部 市场副总监', '负责事业部产品对外推广和宣传，制定各种整合营销的活动；', '执行媒体投放计划，跟踪和监督媒体投放效果，进行数据分析撰写报告；', '向市场总监提供营销支持，并协助相关的公关事宜。', '2019.09-2020.09 信健设计集团 市场部-市场经理', '负责集团SEO优化事宜，在未使用百度竞价排名服务前提下，连接占据首页4至12条；', '参与策划集团年度、季度、月度线下推广活动方案；', '负责线下大型分享会”思享潭“的执行与后期线上推广。'], 'award': ['代表湖南师范大学辩论队参与多项国际型比赛，并取得多项荣誉：', '湖南师范大学“唇舌烽火”辩论赛冠军、亚军；', '湖南师范大学2011级“杰出辩手”；'], 'ability': ['普通话一级甲等', '通过全国计算机二级考试，熟练运用office相关软件。', '熟练使用绘声绘色软件，剪辑过各种类型的电影及班级视频。', '大学英语四/六级（CET-4/6），良好听说读写能力，快速浏览英语专业书籍。'], 'job_fit': ['项目主管'], 'tag': {'edu_tag': ['211', '博士'], 'loc_tag': '湖北', 'experience_tag': ['鼎基设计有限公司', '辉世设计控股集团', '信健设计集团'], 'ability': ['Office办公软件', '计算机等级考试', 'CET6'], 'total_work_time': 4}, 'score': 34.9, 'custom_content': {'money_obj': '', 'self_desc': [], 'self_tag': []}}\n",
                        "{'basic_data': {'name': '蔡依婷', 'age': 30, 'tel': '13912345678', 'email': 'xianxian@taobao.com', 'college': ['北京理工大学'], 'loc': ['上海'], 'edu': '本科'}, 'job_obj': ['设计师'], 'experience': ['在湖南省湘西自治州保靖县木芽村小学义务支教活动，被评为优秀支教老师。修改为自己活动内容介绍。修改为自己内容介绍。', '英语俱乐部干事', '2019.9 – 至今', '智扬顾问有限公司', '平面设计师', '负责企业画册设计、标志设计、产品包装设计、杂志广告跨页设计、户外广告', '对公司的网站后台周期性的修改和维护', '对公司所有的宣传广告全程负责一直到完成阶段', '美铭顾问有限公司', '独立负责过大型项目，非常成功的规划了项目 A 工作；', '2013年担任英语俱乐部主席期间，领导英语俱乐部获得“某年度十佳社团”荣誉称号'], 'award': ['2011年国家励志一等奖学金', '2012年北京理工大学挑战主持人大赛第一名', '2012年北京理工大学演讲比赛三等奖', '2013年全国大学生数学建模大赛国家二等奖', '2014年北京理工大学第九届数学建模大赛一等奖', '2015年参加省红十字协会与校团委主办的演讲比赛并取得前三名的佳绩（全校近200人参赛）'], 'ability': ['Adobe认证设计师', 'Adobe认证产品专家', '平面设计师资格证书', '英语四六级证书', '具备艺术家的灵感创作能力，公司公认的首席 PPT 制作人；', 'MS Office', 'Photoshop', 'Illustrator', '英语', '日语', '粤语'], 'job_fit': ['平面设计师', '产品运营'], 'tag': {'edu_tag': ['985', '本科'], 'loc_tag': '上海', 'experience_tag': ['智扬顾问有限公司', '美铭顾问有限公司'], 'ability': ['Office办公软件', 'Photoshop'], 'total_work_time': 4}, 'score': 24.7, 'custom_content': {'money_obj': '', 'self_desc': [], 'self_tag': []}}\n"
                    ]
                }
            ],
            "source": [
                "sentences1 = ['张吉惟','EXCEL','PPT','WORD','AI','PS','个人技能','出生年月：1998.11','性 别：女','籍 贯：北京海淀区','学 历：本科','政治面貌：党员','身 高：178cm','体 重：50kg','工作经历','自我评价','个人爱好','本人性格开朗、稳重、有活力，待人热情、真诚。有较强的组织能力、团体协作精神，较好的社交能力，善于处理各种人际关系。能迅速的适应各种环境，并融合其中。能把企业当作家庭，企业的财富就是我的财富，在努力为企业服务的过程中实现自身价值。','zhangjiwei@163.com','138 9999 9999','求职意向：行政管理类','基本信息','2016\\t全国大学生英语竞赛一等奖','2017\\t国家级一等奖学金','2018\\t大学英语6级证书（CET-6）','奖励证书','教育背景','2015-2019\\t国际经济与贸易','北京师范大学','政治经济学、西方经济学、国际经济学、计量经济学、世界经济概论、国际贸易理论与实务、国际金融、国际结算。','2022.3至今\\t部长助理','北京猫眼机械有限公司','质管部部长助理.负责票证车间生产质量检查,控制,兼任企业内审员,推行ISO9001:2008及ISO14000体系并年审。','2021.2-2022.3\\t总经理助理','北京猫眼国际货运代理有限公司','根据公司的经营理念和发展战略制定公司各工作岗位的工作目标;负责制定及推进公司员工的培训、绩效、薪酬的管理。','2020.2-2021.2\\t运营助理','北京猫眼文化传媒有限公司','根据目标管理综合考评内容，深入、细致地到所跟踪的各场所了解、掌握情况，帮助和促进各场所提高行政、后勤管理水平。']\n",
                "sentences2 = ['王美珠', '求职目标：市场总监-专注品牌方向', '王美珠', '求职目标：市场总监-专注品牌方向', '出生：1989.05', '住址：湖北省武汉市', '电话：13800138000', '邮箱：service@500d.me', '出生：1989.05', '住址：湖北省武汉市', '电话：13800138000', '邮箱：service@500d.me', '教育背景', '2014.07-2019.06                        湖南师范大学                  市场营销（博士）', '主修课程：管理学、微观经济学、宏观经济学、管理信息系统、统计学、会计学、财务管理、市场营销、经济法、消费者行为学、国际市场营销', '20011.07-2014.06                        湖南师范大学                  市场营销（硕士）', '主修课程：管理学、微观经济学、宏观经济学、管理信息系统、统计学、会计学、财务管理、市场营销、经济法、消费者行为学、国际市场营销', '教育背景', '2014.07-2019.06                        湖南师范大学                  市场营销（博士）', '主修课程：管理学、微观经济学、宏观经济学、管理信息系统、统计学、会计学、财务管理、市场营销、经济法、消费者行为学、国际市场营销', '20011.07-2014.06                        湖南师范大学                  市场营销（硕士）', '主修课程：管理学、微观经济学、宏观经济学、管理信息系统、统计学、会计学、财务管理、市场营销、经济法、消费者行为学、国际市场营销', '工作经历', '2022.09-至今                           辉世设计控股集团                  副总监', '负责协助集团旗下事业部开展各项工作，制定品牌传播方案；', '结合集团与事业部发展，制定营销策略、广告策略、品牌策略和公关策略，并组织推进执行；', '制定和执行媒体投放计划，跟踪和监督媒体投放效果，进行数据分析与撰写报告；', '负责公司品牌形象和价值提升的持续优化，提高品牌知名度；', '研究行业发展动态，定期进行市场调查,为产品更新提供建议。', '工作经历', '2022.09-至今                           辉世设计控股集团                  副总监', '负责协助集团旗下事业部开展各项工作，制定品牌传播方案；', '结合集团与事业部发展，制定营销策略、广告策略、品牌策略和公关策略，并组织推进执行；', '制定和执行媒体投放计划，跟踪和监督媒体投放效果，进行数据分析与撰写报告；', '负责公司品牌形象和价值提升的持续优化，提高品牌知名度；', '研究行业发展动态，定期进行市场调查,为产品更新提供建议。', '校园经历', '2011.09-2012.06                        湖南师范大学                  辩论队（队长）', '任职描述：', '负责50余人团队的日常训练、选拔及团队建设；', '作为负责人对接多项商业校园行活动，如《奔跑吧兄弟》大学站录制、长安福特全球校园行、《时代周末》校园行；', '代表湖南师范大学辩论队参与多项国际型比赛，并取得多项荣誉：', '湖南师范大学“唇舌烽火”辩论赛冠军、亚军；', '湖南师范大学2011级“杰出辩手”；', '2012.11-2014.06                        沟通与交流协会                  创始人/副会长', '任职描述：', '协助湖南省沟通协会湖南师范大学分部，从零开始组建初期团队；', '策划协会会员制，选拔、培训协会导师，推出一系列沟通课程；配合其他社团组织，承办诸如演讲、主持、讲坛等省级/校级活动；', '校园经历', '2011.09-2012.06                        湖南师范大学                  辩论队（队长）', '任职描述：', '负责50余人团队的日常训练、选拔及团队建设；', '作为负责人对接多项商业校园行活动，如《奔跑吧兄弟》大学站录制、长安福特全球校园行、《时代周末》校园行；', '代表湖南师范大学辩论队参与多项国际型比赛，并取得多项荣誉：', '湖南师范大学“唇舌烽火”辩论赛冠军、亚军；', '湖南师范大学2011级“杰出辩手”；', '2012.11-2014.06                        沟通与交流协会                  创始人/副会长', '任职描述：', '协助湖南省沟通协会湖南师范大学分部，从零开始组建初期团队；', '策划协会会员制，选拔、培训协会导师，推出一系列沟通课程；配合其他社团组织，承办诸如演讲、主持、讲坛等省级/校级活动；', '自我评价', '拥有多年的市场管理及品牌营销经验，卓越的规划、组织、策划、方案执行和团队领导能力，积累较强的人际关系处理能力和商务谈判技巧，善于沟通，具备良好的合作关系掌控能力与市场开拓能力；敏感的商业和市场意识，具备优秀的资源整合能力、业务推进能力； 思维敏捷，有培训演讲能力，懂激励艺术，能带动团队的积极性；擅长协调平衡团队成员的竞争与合作的关系，善于通过培训提高团队综合能力和凝聚力。',\n",
                "              '自我评价', '拥有多年的市场管理及品牌营销经验，卓越的规划、组织、策划、方案执行和团队领导能力，积累较强的人际关系处理能力和商务谈判技巧，善于沟通，具备良好的合作关系掌控能力与市场开拓能力；敏感的商业和市场意识，具备优秀的资源整合能力、业务推进能力； 思维敏捷，有培训演讲能力，懂激励艺术，能带动团队的积极性；擅长协调平衡团队成员的竞争与合作的关系，善于通过培训提高团队综合能力和凝聚力。', '掌握技能', '普通话一级甲等', '通过全国计算机二级考试，熟练运用office相关软件。', '熟练使用绘声绘色软件，剪辑过各种类型的电影及班级视频。', '大学英语四/六级（CET-4/6），良好听说读写能力，快速浏览英语专业书籍。', '掌握技能', '普通话一级甲等', '通过全国计算机二级考试，熟练运用office相关软件。', '熟练使用绘声绘色软件，剪辑过各种类型的电影及班级视频。', '大学英语四/六级（CET-4/6），良好听说读写能力，快速浏览英语专业书籍。', '项目经历', '信健设计集团品牌升级发布会', '集团全新品牌logo及VI上线，在多渠道进行了传播；', '企业VIP客户群体逾60人，结合了线上发布、线下体验；', '后续媒体报道持续升温，子品牌罄玉结合代言人罗嘉良制造话题营销，为期3周；', '鼎基设计商业模式发布会', '整场活动以会议+洽谈双重模式进行，首日以介绍鼎基内部平台资源优势，政府背景优势等为主，一对多推介会进行推广普及；', '现场签署地方合作意向书，如：新疆、江西、浙江等优秀企业商户；', '以中国的波尔多为宣传点，主推旗下新疆大型项目，罄玉生态葡萄庄园、沙漠主题俱乐部等，制造营销、品牌热点。', '项目经历', '信健设计集团品牌升级发布会', '集团全新品牌logo及VI上线，在多渠道进行了传播；', '企业VIP客户群体逾60人，结合了线上发布、线下体验；', '后续媒体报道持续升温，子品牌罄玉结合代言人罗嘉良制造话题营销，为期3周；', '鼎基设计商业模式发布会', '整场活动以会议+洽谈双重模式进行，首日以介绍鼎基内部平台资源优势，政府背景优势等为主，一对多推介会进行推广普及；', '现场签署地方合作意向书，如：新疆、江西、浙江等优秀企业商户；', '以中国的波尔多为宣传点，主推旗下新疆大型项目，罄玉生态葡萄庄园、沙漠主题俱乐部等，制造营销、品牌热点。', '2021.09-2022.09                        鼎基设计有限公司                 市场及运营总监', '根据公司发展情况进行战略调整，配合前端销售部门搭建销售渠道；', '负责公司品牌形象和价值提升的持续优化，提高品牌知名度；', '研究行业发展动态，定期进行市场调查,为产品更新提供建议；', '负责公司部门(营运、品牌策划)制度规范，负责组织及监管市场部关于对外合作、渠道管理、媒体合作、推广策划以相关工作的落实。', '2020.09-2021.09                        宏建设计俱乐部                   市场副总监', '负责事业部产品对外推广和宣传，制定各种整合营销的活动；', '执行媒体投放计划，跟踪和监督媒体投放效果，进行数据分析撰写报告；', '向市场总监提供营销支持，并协助相关的公关事宜。', '2019.09-2020.09                        信健设计集团                     市场部-市场经理', '负责集团SEO优化事宜，在未使用百度竞价排名服务前提下，连接占据首页4至12条；', '参与策划集团年度、季度、月度线下推广活动方案；', '负责线下大型分享会”思享潭“的执行与后期线上推广。', '2021.09-2022.09                        鼎基设计有限公司                 市场及运营总监', '根据公司发展情况进行战略调整，配合前端销售部门搭建销售渠道；', '负责公司品牌形象和价值提升的持续优化，提高品牌知名度；', '研究行业发展动态，定期进行市场调查,为产品更新提供建议；', '负责公司部门(营运、品牌策划)制度规范，负责组织及监管市场部关于对外合作、渠道管理、媒体合作、推广策划以相关工作的落实。', '2020.09-2021.09                        宏建设计俱乐部                   市场副总监', '负责事业部产品对外推广和宣传，制定各种整合营销的活动；', '执行媒体投放计划，跟踪和监督媒体投放效果，进行数据分析撰写报告；', '向市场总监提供营销支持，并协助相关的公关事宜。', '2019.09-2020.09                        信健设计集团                     市场部-市场经理', '负责集团SEO优化事宜，在未使用百度竞价排名服务前提下，连接占据首页4至12条；', '参与策划集团年度、季度、月度线下推广活动方案；', '负责线下大型分享会”思享潭“的执行与后期线上推广。']\n",
                "sentences3 = ['蔡依婷', '蔡依婷', '姓名：蔡依婷', '30岁', '籍贯：上海', '民族：汉族', '学历：本科', '专业：设计', '姓名：蔡依婷', '年龄：30岁', '籍贯：上海', '民族：汉族', '学历：本科', '专业：设计', '求 职 意 向 ： 设 计 师', '求 职 意 向 ： 设 计 师', '联系方式', '联系方式', '获得证书', '获得证书', '2011 - 2015', '本科', '2011 - 2015', '本科', '工作经历', '工作经历', 'Adobe认证设计师', 'Adobe认证产品专家', '平面设计师资格证书', '平面设计师资格证书', '英语四六级证书', 'Adobe认证设计师', 'Adobe认证产品专家', '平面设计师资格证书', '平面设计师资格证书', '英语四六级证书', '校园活动', '校园活动', '教育背景', '教育背景', '北京理工大学', '设计专业', '北京理工大学', '设计专业', '13912345678', 'xianxian@taobao.com', '13912345678', 'xianxian@taobao.com', '大学生三下乡', '在湖南省湘西自治州保靖县木芽村小学义务支教活动，被评为优秀支教老师。修改为自己活动内容介绍。修改为自己内容介绍。', '大学生三下乡', '在湖南省湘西自治州保靖县木芽村小学义务支教活动，被评为优秀支教老师。修改为自己活动内容介绍。修改为自己内容介绍。', '党支部书记', '修改成简单的一两句话介绍相关活动经历，活动的内容和获得的成绩。修改为自己活动内容介绍。', '党支部书记', '修改成简单的一两句话介绍相关活动经历，活动的内容和获得的成绩。修改为自己活动内容介绍。', '英语俱乐部干事', '修改成简单的一两句话介绍相关活动经历，活动的内容和获得的成绩。修改为自己活动内容介绍。', '英语俱乐部干事', '修改成简单的一两句话介绍相关活动经历，活动的内容和获得的成绩。修改为自己活动内容介绍。', '学生会主席', '修改成简单的一两句话介绍相关活动经历，活动的内容和获得的成绩。修改为自己活动内容介绍。修改为自己活动内容介绍。', '学生会主席', '修改成简单的一两句话介绍相关活动经历，活动的内容和获得的成绩。修改为自己活动内容介绍。修改为自己活动内容介绍。', '2015.9 – 2019.9', '上海', '2015.9 – 2019.9', '上海', '2019.9 – 至今', '上海', '2019.9 – 至今', '上海', '智扬顾问有限公司', '平面设计师', '智扬顾问有限公司', '平面设计师', '负责企业画册设计、标志设计、产品包装设计、杂志广告跨页设计、户外广告', '对公司的网站后台周期性的修改和维护', '对公司所有的宣传广告全程负责一直到完成阶段', '负责企业画册设计、标志设计、产品包装设计、杂志广告跨页设计、户外广告', '对公司的网站后台周期性的修改和维护', '对公司所有的宣传广告全程负责一直到完成阶段', '美铭顾问有限公司', '平面设计师', '美铭顾问有限公司', '平面设计师', '负责企业画册设计、标志设计、产品包装设计、杂志广告跨页设计、户外广告', '对公司的网站后台周期性的修改和维护', '对公司所有的宣传广告全程负责一直到完成阶段',\n",
                "              '负责企业画册设计、标志设计、产品包装设计、杂志广告跨页设计、户外广告', '对公司的网站后台周期性的修改和维护', '对公司所有的宣传广告全程负责一直到完成阶段', '求 职 意 向 ： 设 计 师', '求 职 意 向 ： 设 计 师', '蔡依婷', '蔡依婷', '13912345678', 'xianxian@taobao.com', '13912345678', 'xianxian@taobao.com', '姓名：奈森设计', '年龄：24岁', '籍贯：上海', '民族：汉族', '学历：本科', '专业：设计', '姓名：奈森设计', '年龄：24岁', '籍贯：上海', '民族：汉族', '学历：本科', '专业：设计', '联系方式', '联系方式', '个人爱好', '个人爱好', '自我评估', '自我评估', '爬山', '写作', '音乐', '瑜伽', '爬山', '写作', '音乐', '瑜伽', '独立负责过大型项目，非常成功的规划了项目 A 工作；', 'B 项目，从开始到完成，极大地加强了我的逻辑思考能力；', '具备艺术家的灵感创作能力，公司公认的首席 PPT 制作人；', '非常优秀的用户心理洞察力，配合丰富的创意及文案能力极大地提高了我的执行力。段前间距设为0.2行。', '专业知识的学习以及多年的工作实践，使我积累了丰富的工作经验，并取得了优秀的销售业绩。段前间距设为0.2行。', '独立负责过大型项目，非常成功的规划了项目 A 工作；', 'B 项目，从开始到完成，极大地加强了我的逻辑思考能力；', '具备艺术家的灵感创作能力，公司公认的首席 PPT 制作人；', '非常优秀的用户心理洞察力，配合丰富的创意及文案能力极大地提高了我的执行力。段前间距设为0.2行。', '专业知识的学习以及多年的工作实践，使我积累了丰富的工作经验，并取得了优秀的销售业绩。段前间距设为0.2行。', 'MS Office', 'Photoshop', 'Illustrator', '英语', '日语', '粤语', 'MS Office', 'Photoshop', 'Illustrator', '英语', '日语', '粤语', '2011年国家励志一等奖学金', '2012年北京理工大学挑战主持人大赛第一名', '2012年北京理工大学演讲比赛三等奖', '2013年全国大学生数学建模大赛国家二等奖', '2013年担任英语俱乐部主席期间，领导英语俱乐部获得“某年度十佳社团”荣誉称号', '2014年北京理工大学第九届数学建模大赛一等奖', '2015年参加省红十字协会与校团委主办的演讲比赛并取得前三名的佳绩（全校近200人参赛）', '2011年国家励志一等奖学金', '2012年北京理工大学挑战主持人大赛第一名', '2012年北京理工大学演讲比赛三等奖', '2013年全国大学生数学建模大赛国家二等奖', '2013年担任英语俱乐部主席期间，领导英语俱乐部获得“某年度十佳社团”荣誉称号', '2014年北京理工大学第九届数学建模大赛一等奖', '2015年参加省红十字协会与校团委主办的演讲比赛并取得前三名的佳绩（全校近200人参赛）', '精通', '熟练', '熟练', '流利', '一般', '流利', '精通', '熟练', '熟练', '流利', '一般', '流利', '掌握技能', '掌握技能', '获奖经历', '获奖经历']\n",
                "print(analysis(sentences1))\n",
                "print(analysis(sentences2))\n",
                "print(analysis(sentences3))"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "import docx2txt\n",
                "import info\n",
                "import tqdm\n",
                "\n",
                "for i in tqdm.notebook.tqdm(range(1, 101)):\n",
                "    if i == 65:\n",
                "        continue\n",
                "    text = docx2txt.process(f\"D:\\\\暂存\\\\CV\\\\{i}.docx\")\n",
                "    lines = text.splitlines()\n",
                "    stripped_lines = [line.strip('\\t').replace('\\t', ' ')\n",
                "                        for line in lines]\n",
                "    sentences = [x for x in stripped_lines if x.strip() != '']\n",
                "    sequence = []\n",
                "    data = [[] for _ in range(7)]\n",
                "    for s in sentences:\n",
                "        p = label_predict(s)\n",
                "        s = re.sub(r'[\\s\\t]{2,}', ' ', s.strip())\n",
                "        sequence.append([s, p])\n",
                "\n",
                "    # 上下文纠正算法 纠正特殊标签6 这里有两种可能 6,2->6,1 或 6,2->2,2\n",
                "    for j in range(0, len(sequence)-1):\n",
                "        if sequence[j][1] == 6 and sequence[j+1][1] == 2:\n",
                "            job_obj_patter = '|'.join(info.job_obj_keywords())\n",
                "            matches = re.findall(job_obj_patter, sequence[j][0])\n",
                "            if matches:\n",
                "                # 6,2->6,1\n",
                "                sequence[j+1][1] = 1\n",
                "            else:\n",
                "                # 6,2->2,2\n",
                "                sequence[j][1] = 2\n",
                "\n",
                "    # 至此分类完成\n",
                "    for s in sequence:\n",
                "        data[s[1]].append(s[0])\n",
                "\n",
                "    # job = ''.join(data[2])+'&'+str(mp[i])+'\\n'\n",
                "    # file.write(job)\n",
                "    print(analysis(''.join(data[2])))\n",
                "\n",
                "    # print(f\"简历{i} - {analysis(new_list)['job_fit']}\")\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "# ner测试\n",
                "input_sentence = '北京时光印象信息科技有限公司 推广组实习生 2016.03-2016.5'\n",
                "output_prediction = ner_predict(input_sentence)\n",
                "print(f'姓名{list(output_prediction[0])},组织{list(output_prediction[1])},地点{list(output_prediction[2])}')\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "# 分类测试\n",
                "label = {\n",
                "    0: '基本信息',\n",
                "    1: '求职意向',\n",
                "    2: '工作/项目经历',\n",
                "    3: '获得奖项',\n",
                "    4: '个人能力',\n",
                "    5: '垃圾信息',\n",
                "    6: '重要标注'\n",
                "}\n",
                "sentences = [\n",
                "    '重庆大学-市场营销',\n",
                "    '恩汇信息科技有限公司 产品经理',\n",
                "    'Reaaasdqweeeeeefsdsdfasdasd', 'adsdasfvcasDDa', '中国石油大学  物理系',\n",
                "    '2018.05-2019.06   辩论队（队长）',\n",
                "    '许爱礼',\n",
                "    '根据公司发展情况进行战略调整，配合前端销售部门搭建销售渠道；',\n",
                "    '东城区公安局某某分局政工监督室                                 2017.08-2018.08',\n",
                "    '风雨工作室                                               2018.08-2021.02',\n",
                "'2018.2-2018.12做过一家小型民营企业的兼职行政文员，对行政文资工作有了初步的认识。实习经历也写在此栏目。',\n",
                "'大二期间担任系学生会生活部部长，锻炼了自己的组织协调能力；实习经历也写在此栏目。段前间距设为0.3行',\n",
                "'大一、大二期间担任校市场研究会干事，参与组织多次研讨会；实习经历也写在此栏目。段前间距设为0.3行。',\n",
                "'大三期间担任学生会生活部部长，组织多次校园活动，都取得了不错的效果；实习经历也写在此栏目',\n",
                "'利用大二署假参加学校组织的“三下乡”活动，加深了对社会的了解。段前间距设为0.3行。',\n",
                "\n",
                "]\n",
                "\n",
                "for s in sentences:\n",
                "    p = label_predict(s)\n",
                "    print(f'{s} -- {label[p]}')\n"
            ]
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": "Python 3",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.11.0"
        },
        "orig_nbformat": 4
    },
    "nbformat": 4,
    "nbformat_minor": 2
}
